package guiWindows;

import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import javax.swing.JComboBox;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;

public class GUISelectActivity extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JComboBox<String> listActivities = null;
	private JPanel buttonPanel = null;  //  @jve:decl-index=0:visual-constraint="616,98"
	private JButton okButton = null;
	private JButton cancelButton = null;

	public GUISelectActivity() {
		super();
		initialize();
	}

	private void initialize() {
		this.setSize(300, 95);
		this.setTitle("Select Activity");
		this.setLocationRelativeTo(null);
		this.setModal(true);
		this.setContentPane(getJContentPane());
	}

	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getListActivities(), BorderLayout.CENTER);
			jContentPane.add(getButtonPanel(), BorderLayout.SOUTH);
		}
		return jContentPane;
	}

	public JComboBox<String> getListActivities() {
		if (listActivities == null) {
			listActivities = new JComboBox<String>();
			listActivities.setPreferredSize(new Dimension(300, 20));
		}
		return listActivities;
	}

	private JPanel getButtonPanel() {
		if (buttonPanel == null) {
			buttonPanel = new JPanel();
			buttonPanel.setLayout(new FlowLayout());
			buttonPanel.setSize(new Dimension(241, 69));
			buttonPanel.add(getOkButton(), null);
			buttonPanel.add(getCancelButton(), null);
		}
		return buttonPanel;
	}

	public JButton getOkButton() {
		if (okButton == null) {
			okButton = new JButton("OK");
		}
		return okButton;
	}

	public JButton getCancelButton() {
		if (cancelButton == null) {
			cancelButton = new JButton("CANCEL");
		}
		return cancelButton;
	}

	public void setListenerButtons(ActionListener al){
		this.okButton.addActionListener(al);
		this.cancelButton.addActionListener(al);
	}
}
